<?php
/**
 * @deprecated
 */
class test{
    
}

ini_set('display_errors', 1);
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ^ E_DEPRECATED);
ini_set('memory_limit', '1024M');

require_once '/data/wwwroot/g_vendor/autoload.php';

use Doraemon\tools\LinkFormat;

$start = time();
$fileName = 'data.xlsx';
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($fileName);
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
$data['num'] = count($sheetData) - 1;
$send_data = [];
if ($sheetData && is_array($sheetData)) {
    foreach ($sheetData as $i => $goods_item) {
        if ($i < 2) {
            continue;
        }

        if (isset($goods_item['A']) && $goods_item['A']) {
            $res = pushMsg((int)trim($goods_item['A']), $goods_item['C']);
            if ($res) {
                $send_data[] = $goods_item['A'];
            }
        }
    }
}
\Biz\cache\brand\BlindBox::setItem('send_data', $send_data, 60 * 60 * 24);

$end = time();
var_dump(date('Y-m-d-H-i-s') . '共' . $data['num'] . '条数据，发送完成,总耗时:' . ($end - $start) . '秒，' . (($end - $start) / 60) . '分');

function pushMsg($uid, $brand_name)
{
    $link = 'https://m.haohaozhu.cn/brand/new-product-express';
    $link = LinkFormat::encryptionLink($link);
    $pushId = 'brand_new_product_' . date('Y_m_d');
    $params = [
        'uid' => $uid,
        'title' => '你关注的' . trim($brand_name) . '有新品啦！',
        'alert' => '618逛值得买新品，参与活动有机会抽大奖哦！',
        'param' => [
            'link' => $link,
            'push_id' => $pushId,
            'image' => ''
        ]
    ];
    \Doraemon\service\Push\PushService::send($params);
}







